package com.jz.netthings.analysis.bean;

import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import lombok.Data;

import java.io.Serializable;
import java.lang.reflect.Method;

/**
 * <p>
 * 供浆者轮次
 * </p>
 *
 * @author yangyunyun
 * @since 2019-07-16
 */
@Data
public class ProviderRound implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 浆员ID
     */
    @TableField("providerId")
    private Long providerId;
    /**
     * 年份
     */
    private Integer year;
    /**
     * 第一轮
     */
    private String round1;
    /**
     * 第二轮
     */
    private String round2;
    /**
     * 第三轮
     */
    private String round3;
    private String round4;
    private String round5;
    private String round6;
    private String round7;
    private String round8;
    private String round9;
    private String round10;
    private String round11;
    private String round12;
    private String round13;
    private String round14;
    private String round15;
    private String round16;
    private String round17;
    private String round18;
    private String round19;
    private String round20;
    private String round21;
    private String round22;
    private String round23;
    private String round24;
    private String round25;
    private String round26;

    public ProviderRound() {}
    public ProviderRound(boolean setRoundTo0) {
        if (setRoundTo0){
            this.setRoundTo0();
        }
    }

    public void setRoundTo0(){
        try {
            Class<?> clazz = this.getClass();
            for(int i=1;i<27;i++){
                Method setRound = clazz.getMethod("setRound"+i, String.class);
                setRound.invoke(this, "0");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 设置某一个轮次的值
     * @param roundIdx
     * @param roundResult
     */
    public void setRound(String roundIdx,String roundResult){
        try {
            Class<?> clazz = this.getClass();
            Method setRound = clazz.getMethod("setRound" + roundIdx, String.class);
            setRound.invoke(this, roundResult);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
